<template>
<van-sticky z-index="100">
    <van-nav-bar
      title="订单详情"
      left-text="返回"
      left-arrow
      @click-left="onBack"
    />
  </van-sticky>
    <div class="list">
                    <!-- 一个item代表一个订单 -->
                    <div class="item">
                        <div class="header">
                            <div class="left">
                                订单号：<span>{{ list.code }}</span>
                            </div>
                            <div class="footer">
                            <div class="date">{{ list.createtime_text }}</div>
                            
                        </div>
                            
                        </div>
                        <div class="content">
                            <van-card
                                v-for="son in list.order_product"
                                :key="son.id"
                                :num="son.nums"
                                :price="son.total"
                                :title="son.products.name"
                                :thumb="son.products.thumb_cdn"
                            >
                                <template #desc>
                                    <span>商品单价：￥{{ son.price }}</span>
                                </template>
                            </van-card>
                        </div>
                        
                        <div>总金额：{{list.amount}}</div>
                        <div class="right">{{ list.status_text }}</div>
                    </div>
    </div>
    <br>
    <div>收货地址</div>
    <div>姓名：{{address.consignee}}</div>
    <div>电话：{{address.mobile}}</div>
    <div>收货地址：{{address.address}}</div>
    <!-- <div>{{address}}</div> -->


</template>

<script setup>
import { getCurrentInstance, ref, reactive, onMounted } from "vue";

const { proxy } = getCurrentInstance();
const id = ref(proxy.$route.query.id ? proxy.$route.query.id : 0);
const businessaddrid = ref(proxy.$route.query.businessaddrid ? proxy.$route.query.businessaddrid : 0);
const business = reactive(
    proxy.$cookies.get("business") ? proxy.$cookies.get("business") : {}
);

const list = ref([]);
const address = ref([]);

onMounted(() => {
    getOrderData();
    
});

const getOrderData = async () => {
    let data = {
        busid:business.id,
        id:id.value,
        businessaddrid:businessaddrid.value
    };

    let result = await proxy.$api.OrderDetail(data);

    if(result.code === 0)
    {
        proxy.$showNotify({
            type:'warning',
            message:result.msg,
            duration:1500,

        });

        return;
    }

    // let Data = result.data;
    address.value = result.data.address;
    list.value = result.data.list;
    // list.value = list.value.concat(Data.list);
};

const onBack = () => {
  proxy.$router.go(-1);
  return;
};
</script>